package com.mvc.framework.entity;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;

public class FillForm {
	public FillForm() {
	}

	public static ActionFom fill (String formClass, HttpServletRequest request) {
		ActionFom form = null;
		try {
			Class claz = Class.forName(formClass);
			form = (ActionFom) claz.newInstance();
			Field[] fields = claz.getDeclaredFields();
			for (Field f : fields) {
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("严重：Form 装载失败！");
		}
		return form;
	}
}
